//package com.boot;
//
//import com.alibaba.dubbo.rpc.service.GenericException;
//import com.boot.domain.ServiceResponse;
//import org.springframework.util.CollectionUtils;
//import org.springframework.web.bind.MethodArgumentNotValidException;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.validation.ConstraintViolation;
//import javax.validation.ConstraintViolationException;
//import java.util.Set;
//
///**
// * @author songlin.an
// * @className GlobalExceptionHandler
// * @description 全局异常处理器
// * @date 2023/4/19 11:29
// **/
//@ControllerAdvice
//public class GlobalExceptionHandler  {
//
//    @ExceptionHandler(MethodArgumentNotValidException.class)
//    @ResponseBody
//    public ServiceResponse handleMethodArgumentNotValidException(ConstraintViolationException ex) {
//        Set<ConstraintViolation<?>> constraintViolations = ex.getConstraintViolations();
//        if(!CollectionUtils.isEmpty(constraintViolations)){
//            String message = constraintViolations.iterator().next().getMessage();
//            return ServiceResponse.failureResponse("400","参数错误: " + message);
//
//        }
//        return ServiceResponse.failureResponse("400","参数错误: ");
//    }
//    @ExceptionHandler(MethodArgumentNotValidException.class)
//    @ResponseBody
//    public ServiceResponse handleMethodArgumentNotValidException(RuntimeException ex) {
//        return ServiceResponse.failureResponse("400","参数错误: ");
//    }
//
//    @ExceptionHandler(MethodArgumentNotValidException.class)
//    @ResponseBody
//    public ServiceResponse handleMethodArgumentNotValidException(Exception ex) {
//        return ServiceResponse.failureResponse("400","参数错误: ");
//    }
//}
